package com.smy.jkds.advice;

import com.smy.jkds.po.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author z01140
 * @Package: com.smy.jkds.advice
 * @Description:
 * @CreateDate 2021/10/30 16:23
 * @UpdateDate 2021/10/30 16:23
 */

@Slf4j
@RestControllerAdvice
public class ControllerAdvice {

    @ResponseBody
    @ExceptionHandler
    public Result exceptionHandler(Exception e) {
        //统一处理异常,返回规定的json格式
        log.error("", e);
        return Result.error(e.getMessage());
    }
}
